home *** CD-ROM | disk | FTP | other *** search
GW-BASIC | 1997-01-29 | 21.8 KB | 730 lines |
- 10 'PATHFIND - Combined GRCIRCL & LATLONG programs - 02 APR 92 rev. 28 JAN 97
- 20 COMMON EX$,PROG$
- 30 IF EX$=""THEN EX$="EXIT"
- 40 PROG$="pathfind"
- 50 GO$="latlong"
- 60 IF LIB=1 THEN 380 'LIB = data already loaded flag
- 70 IF POSN THEN 380
- 80 LIB=1
- 90 ON ERROR GOTO 210
- 100 CLS:KEY OFF
- 110 COLOR 7,0,1
- 120 DIM A$(1024,4),F$(50,2)
- 130 U1$="#####.#":U2$="##,###.#":U3$="####.#":U4$="####,###.#":U5$="###.#"
- 140 UL$=STRING$(80,205)
- 150 XX$=STRING$(79,32) 'blank
- 160 E$=CHR$(248) '<UNK! {00F8}> symbol
- 170 PI=3.14159
- 180 IF BASEONLY=1 THEN GOSUB 250:GOTO 4020 'run database only
- 190 GOSUB 260:GOTO 380
- 200 '
- 210 '.....error trap
- 220 PRINT "Error";ERR;"in line";ERL;"...Press any key to start over..."
- 230 IF INKEY$=""THEN 230
- 240 RUN EX$
- 250 '
- 260 '.....load data
- 270 PRINT " LOADING DATA from DISK - Please stand by......"
- 280 OPEN "I",1,"\data\latlong\LATLONG.DAT"
- 290 IF EOF(1) THEN 350
- 300 N=N+1
- 310 FOR Y=1 TO 4
- 320 INPUT# 1,A$(N,Y)
- 330 NEXT Y
- 340 GOTO 290
- 350 CLOSE
- 360 RETURN
- 370 '
- 380 '.....start
- 390 CLS
- 400 IF LATLONG=1 THEN LATLONG=0:GOTO 4020 'latlong program
- 410 COLOR 15,2
- 420 PRINT " GREAT CIRCLE PATHS, BEARINGS and DISTANCES";
- 430 PRINT TAB(57);"by George Murphy VE3ERP ";
- 440 COLOR 1,0:PRINT STRING$(80,223);
- 450 COLOR 7,0
- 460 IF POSN THEN Z=POSN:GOSUB 1250:GOTO 950
- 470 '
- 480 GOSUB 6960 'preface
- 490 PRINT UL$;
- 500 PRINT " Press number in < > to:"
- 510 PRINT UL$;
- 520 PRINT " < 1 > RUN program"
- 530 PRINT " < 2 > VIEW/EDIT/SEARCH data files (Latitude/Longitude Data Base)"
- 540 PRINT UL$;
- 550 PRINT " < 0 > EXIT"
- 560 Z$=INKEY$
- 570 IF Z$="0"THEN CLS:RUN EX$
- 580 IF Z$="1"THEN GOSUB 620:GOTO 740
- 590 IF Z$="2"THEN CLS:CHAIN"latlong"
- 600 GOTO 560
- 610 '
- 620 '....units of distance
- 630 VIEW PRINT 3 TO 24:CLS:VIEW PRINT:LOCATE 3
- 640 PRINT " Press letter in < > to select units of distance:"
- 650 PRINT UL$;
- 660 PRINT " < n > Nautical miles"
- 670 PRINT " < s > Statute miles"
- 680 PRINT " < k > Kilometers"
- 690 Z$=INKEY$
- 700 IF Z$="n"OR Z$="s"OR Z$="k"THEN FAR$=Z$:GOTO 720
- 710 GOTO 690
- 720 RETURN
- 730 '
- 740 '.....instructions
- 750 VIEW PRINT 3 TO 24:CLS:VIEW PRINT:LOCATE 3,2
- 760 COLOR 0,7:PRINT " NOTE: ":COLOR 7,0
- 770 PRINT
- 780 PRINT " Enter latitude and longitude as decimal degrees, to the nearest ";
- 790 PRINT "1/10th of a"
- 800 PRINT " degree, e.g. 47.3 for 48<UNK! {00F8}>20'. If you enter data with more than ";
- 810 PRINT "one place of"
- 820 PRINT " decimals the data entered will be used in all calculations, even ";
- 830 PRINT "though all"
- 840 PRINT " data displayed will be rounded-off to the nearest 1/10th degree."
- 850 PRINT
- 860 PRINT " 1/10th of a degree longitude is equal to about 11 kilometers ";
- 870 PRINT "at the equator,"
- 880 PRINT " less than 6 Km. at 60<UNK! {00F8}> latitude."
- 890 PRINT
- 900 PRINT UL$;
- 910 '
- 920 '.....inputs
- 930 P$(1)="A ":P$(2)="B "
- 940 '
- 950 LOCATE 15
- 960 IF POSN THEN ZZ=POSN ELSE ZZ=1
- 970 IF POSN<>1 THEN 1030
- 980 GOSUB 1230
- 990 IF Z=1 THEN PRINT "Point A:"
- 1000 PRINT "Latitude of ";P$(Z);USING U2$;ABS(LA(Z));:PRINT NS$(Z)
- 1010 PRINT "Longitude of ";P$(Z);USING U2$;ABS(LO(Z));:PRINT EW$(Z)
- 1020 '
- 1030 FOR Z=ZZ TO 2 '********** start input loop **********
- 1040 DOT$=STRING$(39-LEN(P$(Z)),".")
- 1050 IF POSN=Z THEN GOSUB 1230:GOTO 1290
- 1060 IF(P$(Z)<>"" AND LA(Z)*LO(Z))THEN 1290
- 1070 COLOR 0,7:LOCATE CSRLIN,7
- 1080 PRINT" (ENTER <x> to access data on file or enter latitude:";
- 1090 COLOR 7,0
- 1100 PRINT" ENTER: Latitude (minus if South) of ";P$(Z);:INPUT I$
- 1110 IF I$="x"OR I$="X"THEN POSN=Z:CLS:GOTO 4020 'latlong program
- 1120 LA(Z)=VAL(I$):GOSUB 1230
- 1130 FOR CL=CSRLIN-2 TO CSRLIN:LOCATE CL:PRINT XX$:NEXT CL
- 1140 LOCATE CSRLIN-3,8
- 1150 PRINT " Latitude of ";P$(Z);DOT$;USING U2$;ABS(LA(Z));:PRINT NS$(Z)
- 1160 PRINT" ENTER: Longitude (minus if West) of ";P$(Z);:INPUT LO(Z)
- 1170 GOSUB 1230
- 1180 FOR CL=CSRLIN-1 TO CSRLIN:LOCATE CL:PRINT XX$:NEXT CL
- 1190 LOCATE CSRLIN-2,8
- 1200 PRINT " Longitude of ";P$(Z);DOT$;USING U2$;ABS(LO(Z));:PRINT EW$(Z)
- 1210 GOTO 1290
- 1220 '
- 1230 IF SGN(LA(Z))=-1 THEN NS$(Z)=E$+"S "ELSE NS$(Z)=E$+"N "
- 1240 IF SGN(LO(Z))=-1 THEN EW$(Z)=E$+"W "ELSE EW$(Z)=E$+"E "
- 1250 RLA(Z)=LA(Z)*PI/180 'latitude in radians
- 1260 RLO(Z)=LO(Z)*PI/180 'longitude in radians
- 1270 RETURN
- 1280 '
- 1290 IF MID$(P$(Z),2)=" "THEN 1300 ELSE 1450
- 1300 PRINT " Do you want to name ";P$(Z);"? (y/n)"
- 1310 Z$=INKEY$
- 1320 IF Z$="n"OR Z$="N"THEN LOCATE CSRLIN-1:PRINT XX$:LOCATE CSRLIN-1:GOTO 1450
- 1330 IF Z$="y"OR Z$="Y"THEN 1360
- 1340 GOTO 1310
- 1350 '
- 1360 LOCATE CSRLIN-1:PRINT XX$:LOCATE CSRLIN-1
- 1370 PRINT " ENTER: Name of ";P$(Z);" ? ";:LINE INPUT P$(Z)
- 1380 FOR X=1 TO LEN(P$(Z))
- 1390 V=ASC(MID$(P$(Z),X)):IF V<97 OR V>122 THEN 1410
- 1400 MID$(P$(Z),X)=CHR$(V-32)
- 1410 NEXT X
- 1420 X=0:LOCATE CSRLIN-1:PRINT XX$
- 1430 FOR CL=CSRLIN-3 TO CSRLIN-2:LOCATE CL,22:PRINT P$(Z):NEXT CL
- 1440 '
- 1450 NEXT Z '********** end input loop **********
- 1460 '
- 1470 ROUTE=SGN(LA(1)+LA(2)) 'determine north or south route
- 1480 IF LA(1)<0 AND LA(2)<0 THEN ROUTE=1 'A & B both in southern hemisphere
- 1490 '
- 1500 '.....display initial Pathfind data
- 1510 VIEW PRINT 3 TO 23:CLS:VIEW PRINT 'erase screen
- 1520 LOCATE 3
- 1530 Z=1:GOSUB 1230
- 1540 PRINT TAB(8);"Path between";
- 1550 DOT$=STRING$(39-LEN(P$(1)),".")
- 1560 PRINT TAB(21);P$(1);" ";DOT$;
- 1570 PRINT TAB(61);USING U1$;ABS(LA(1));
- 1580 PRINT NS$(1);USING U1$;ABS(LO(1));
- 1590 PRINT EW$(1);
- 1600 LOCATE CSRLIN-1,44:PRINT " Solar zone UTC";USING "+##";LO(1)/15;
- 1610 Z=2:GOSUB 1230
- 1620 PRINT TAB(13);" and";
- 1630 DOT$=STRING$(39-LEN(P$(2)),".")
- 1640 PRINT TAB(21);P$(2);" ";DOT$;
- 1650 PRINT TAB(61);USING U1$;ABS(LA(2));
- 1660 PRINT NS$(2);USING U1$;ABS(LO(2));
- 1670 PRINT EW$(2);
- 1680 LOCATE CSRLIN-1,44:PRINT " Solar zone UTC";USING "+##";LO(2)/15;
- 1690 GOSUB 1790 'to make B > A
- 1700 MERID=0 'default value
- 1710 IF LO(1)=LO(2)THEN MERID=1:GOTO 1760 'A & B on same meridian
- 1720 IF ABS(LO(1))+ABS(LO(2))<>180 THEN 1760
- 1730 LA(2)=180-LA(2):MERID=1 'A & B on opposite meridians
- 1740 IF LA(2)>180 THEN LA(2)=LA(2)-90
- 1750 RLA(2)=LA(2)*PI/180 'angle in radians
- 1760 GOSUB 3350 'calculation sub-routine
- 1770 GOTO 1890 'screen print
- 1780 '
- 1790 '.....point B must be place of greater latitude
- 1800 ALA=RLA(1):BLA=RLA(2)
- 1810 IF(ALA=BLA)AND(RLO(1)>RLO(2))THEN 1840 'both on equator
- 1820 IF (ALA<0)AND(BLA<0)THEN ALA=ABS(ALA):BLA=ABS(BLA) 'both south of equator
- 1830 IF BLA>ALA THEN 1870
- 1840 SWAP RLA(1),RLA(2)
- 1850 SWAP RLO(1),RLO(2)
- 1860 SWAP P$(1),P$(2)
- 1870 RETURN
- 1880 '
- 1890 '.....display balance of Pathfind data
- 1900 LONDIFF=ABS(LO(1)-LO(2)) 'difference in longitude
- 1910 IF LONDIFF >180 THEN LONDIFF=360-LONDIFF
- 1920 HR=LONDIFF
- 1930 ZONE=LONDIFF/15 'no. of 1 hr.time zones
- 1940 HR=ZONE
- 1950 T=21
- 1960 IF FAR$=""THEN FAR$="n" 'default
- 1970 IF FAR$="n"THEN DIST=ZD*60:DIST$=" Naut.Miles":GOTO 2000
- 1980 IF FAR$="s"THEN DIST=ZD*24856.8/360:DIST$=" Stat.Miles":GOTO 2000
- 1990 IF FAR$="k"THEN DIST=ZD*40000/360:DIST$=" Kilometers"
- 2000 PRINT TAB(T);"Great Circle distance (";DIST$;" )";STRING$(4,".");" ";
- 2010 PRINT USING U2$;DIST;
- 2020 PRINT TAB(T);"Solar Time difference";STRING$(19,".");
- 2030 PRINT USING "#######.##";HR;:PRINT " hrs."
- 2040 D1$=STRING$(27-LEN(P$(1)),".")
- 2050 PRINT TAB(T);"Bearing from ";P$(1);D1$;TAB(64);USING U3$;XD;
- 2060 PRINT CHR$(248)
- 2070 D2$=STRING$(27-LEN(P$(2)),46)
- 2080 PRINT TAB(T);"Bearing from ";P$(2);D2$;TAB(64);USING U3$;YD;
- 2090 PRINT CHR$(248)
- 2100 '
- 2110 '.....intermediate plots
- 2120 IF MERID<>1 THEN 2140
- 2130 IF LO(1)<>LO(2)THEN LB=PI-LB
- 2140 IF RLO(1)<0 THEN RLO(1)=2*PI+RLO(1)
- 2150 IF RLO(2)<0 THEN RLO(2)=2*PI+RLO(2)
- 2160 COLOR 1,0:PRINT STRING$(80,223);
- 2170 COLOR 0,7
- 2180 LOCATE CSRLIN-1,21:PRINT " I N T E R M E D I A T E P L O T S "
- 2190 COLOR 7,0
- 2200 PRINT " To ";P$(1);
- 2210 T=80-3-LEN(P$(2))
- 2220 PRINT TAB(T);"To ";P$(2);
- 2230 PRINT " CLSSOUNDDEFSNG";TAB(6);DIST$;
- 2240 PRINT TAB(18);"DEFSNGSOUND Bearing";
- 2250 PRINT TAB(29);"DEFSNGSOUND VARPTRSOUNDSOUND From Plot SOUNDSOUNDCOLOR SOUNDDEFDBL";
- 2260 PRINT TAB(53);"Bearing SOUNDDEFDBL";
- 2270 PRINT TAB(63);DIST$;TAB(76);"DEFDBLSOUND'"
- 2280 PRINT UL$;
- 2290 '
- 2300 '.....loop for intermediate plots
- 2310 NP=11 'no. of plots
- 2320 IF ZR<PI/200 THEN 3200 'A & B closer than 100 Km apart
- 2330 D=NP+1 'no.of segments
- 2340 DS=(ZR/D) 'interval distance angle
- 2350 HOLD=N 'hold N=no. of locations on file
- 2360 FIRST=RLO(1) 'longitude of start plot
- 2370 '
- 2380 FOR N=NP TO 1 STEP-1 '******************START LOOP********************
- 2390 '
- 2400 '.....find latitude of plot
- 2410 REM LA=latitude of FIRST
- 2420 REM X=bearing FIRST
- 2430 DA=DS*N 'segment distance angle
- 2440 SEG=N/D*DIST 'segment distance
- 2450 IF ROUTE<>0 THEN DA=DA*ROUTE 'route can be north or south
- 2460 IF EQUAT THEN LAP=PI/2:PLAP=PI/2:PLA=0:GOTO 2540
- 2470 IF MERID THEN PLA=LA+DA:GOTO 2570
- 2480 LAP=PI/2-LA 'angle between LA & pole
- 2490 A=COS(LAP)*COS(DA)+SIN(LAP)*SIN(DA)*COS(X) 'law of cosines for sides
- 2500 ANGL=ATN(A/SQR(-A*A+1)) 'angle between plot & pole
- 2510 PLAP=ABS(ANGL-PI/2)
- 2520 PLA=PI/2-PLAP 'latitude of plot
- 2530 '
- 2540 '.....find longitude of plot
- 2550 B=(COS(DA)-COS(PLAP)*COS(LAP))/SIN(PLAP)/SIN(LAP) 'law of cosines for sides
- 2560 NOTE=0:IF ABS(B)>=1 THEN B=1:BEEP:NOTE=1 'round-off inaccuracy
- 2570 IF MERID THEN PLO=FIRST:PLOD=0:GOTO 2700
- 2580 PLOD=ATN(B/SQR(-B*B+1))+PI/2 'difference in longitude
- 2590 '
- 2600 IF PLOD<PI/2 THEN PLOD=PI/2-PLOD+PI/2:GOTO 2630
- 2610 IF PLOD>PI/2 THEN PLOD=PI-PLOD
- 2620 '
- 2630 IF RLO(2)-FIRST>PI THEN RLO(2)=RLO(2)-2*PI 'path crossing 0<UNK! {00F8}> meridian
- 2640 IF FIRST-RLO(2)>PI THEN RLO(2)=RLO(2)+2*PI
- 2650 IF FIRST<RLO(2)THEN PLO=FIRST+PLOD
- 2660 IF FIRST>RLO(2)THEN PLO=FIRST-PLOD
- 2670 IF PLO<0 THEN PLO=PLO+2*PI
- 2680 IF PLO>2*PI THEN PLO=PLO-2*PI
- 2690 '
- 2700 PLAN=PLA
- 2710 IF MERID <>1 THEN 2740
- 2720 IF PLAN>PI/2 THEN PLAN=PI-PLAN:PLO=PLO+PI
- 2730 IF PLAN<-PI/2 THEN PLAN=PI+PLAN:PLO=PLO+PI
- 2740 PLON=PLO 'location for printout
- 2750 IF PLON>PI THEN PLON=2*PI-PLON
- 2760 RLA(2)=PLA:RLO(2)=PLO 'new start point
- 2770 GOSUB 3350 'calculate bearings
- 2780 '
- 2790 '.....display plot headings & distance
- 2800 REM Y=bearing to P$(1)
- 2810 YR=Y+PI 'reciprocal heading to P$(2)
- 2820 IF YR>2*PI THEN YR=YR-2*PI
- 2830 IF FAR$="n"THEN D1=NM:D2=DIST-D1 'distance - nautical miles
- 2840 IF FAR$="s"THEN D1=SM:D2=DIST-D1 'distance - nautical miles
- 2850 IF FAR$="k"THEN D1=KM:D2=DIST-D1 'distance - nautical miles
- 2860 '
- 2870 '.....display plots
- 2880 N$=STR$(NP-N+1):IF LEN(N$)=2 THEN N$=" "+N$
- 2890 N$=RIGHT$(N$,2)
- 2900 E$=CHR$(248) '<UNK! {00F8}> degree symbol
- 2910 '
- 2920 PRINT " ";N$; 'plot no.
- 2930 PRINT TAB(7); 'set margin
- 2940 PRINT USING U4$;ABS(SEG);:PRINT " "; 'distance
- 2950 E$=CHR$(248) '<UNK! {00F8}> degree symbol
- 2960 PRINT USING U1$;Y*180/PI;:PRINT E$; 'bearing
- 2970 PRINT " DEFSNGSOUND"; 'left arrow
- 2980 IF PLAN<0 THEN NS$=E$+"S"ELSE NS$=E$+"N"
- 2990 COLOR 0,7
- 3000 PRINT USING U3$;ABS(PLAN*180/PI);:PRINT NS$; 'latitude
- 3010 IF PLO>PI AND PLO<2*PI THEN EW$=E$+"W"ELSE EW$=E$+"E"
- 3020 PRINT USING U1$;ABS(PLON)*180/PI;:PRINT EW$;" "; 'longitude
- 3030 COLOR 7,0
- 3040 PRINT "SOUNDDEFDBL"; 'right arrow
- 3050 RY=YR*180/PI:IF CINT(RY)=360 THEN RY=0
- 3060 PRINT USING U1$;RY;:PRINT E$;" "; 'bearing
- 3070 PRINT USING U4$;ABS(DIST-SEG);:PRINT " "; 'distance
- 3080 IF N=3 OR N=9 THEN COLOR 0,7:PRINT "1/4 way";
- 3090 IF N=4 OR N=8 THEN COLOR 0,7:PRINT "1/3 way";
- 3100 IF N=6 THEN COLOR 0,7:PRINT "1/2 way";
- 3110 COLOR 7,0
- 3120 PRINT "" 'end of line
- 3130 '
- 3140 NEXT N '******************END LOOP*********************
- 3150 IF NOTE THEN 3170
- 3160 PRINT UL$;
- 3170 N=HOLD 'N=no. of locations on file
- 3180 GOTO 3260
- 3190 '
- 3200 '.....A & B very close together
- 3210 COLOR 14,12
- 3220 PRINT " Intermediate plots are redundant for locations less than 100 ";
- 3230 PRINT "km. apart"
- 3240 COLOR 7,0
- 3250 '
- 3260 IF NOTE=0 THEN 3310
- 3270 COLOR 14,12
- 3280 PRINT " SOME PLOT BEARINGS MAY BE INACCURATE DUE TO CALCULATION ";
- 3290 PRINT "ROUNDING-OFF ERRORS";
- 3300 COLOR 7,0
- 3310 GOSUB 7170:GOTO 6880 'screen dump/exit option
- 3320 '
- 3330 '**********SUB-ROUTINES**********
- 3340 '
- 3350 '.....calculate bearings and distance
- 3360 REM RLA(n) & RLO(n) are LAT & LONG inputs in radians
- 3370 LB=RLA(2) 'latitude of point B in radians
- 3380 LA=RLA(1) 'latitude of point A in radians
- 3390 IF LA=0 AND LB=0 THEN 3580 'both points on equator
- 3400 C=RLO(1)-RLO(2) 'difference in longitude
- 3410 IF C=0 THEN 3450 'both points on same meridian
- 3420 IF ABS(C)=PI THEN 3510 'points on opposite meridian
- 3430 GOTO 3670
- 3440 '
- 3450 '.....A & B both on same meridian
- 3460 ZR=LB-LA:ZD=ZR*180/PI
- 3470 Y=PI:YD=180
- 3480 X=0:XD=0
- 3490 RETURN
- 3500 '
- 3510 '.....A & B on opposite meridians
- 3520 ZR=LB-LA:IF ZR>PI THEN ZR=2*PI-ZR
- 3530 IF ZR<PI THEN Y=0:YD=0:X=0:XD=0
- 3540 IF ZR>PI THEN Y=PI:YD=180:X=PI:XD=180
- 3550 ZD=ZR*180/PI
- 3560 RETURN
- 3570 '
- 3580 '.....A & B both on equator
- 3590 EQUAT=1 'flag
- 3600 Y=PI/2:YD=Y*180/PI
- 3610 X=1.5*PI:XD=X*180/PI
- 3620 L=ABS(RLO(1)-RLO(2))
- 3630 IF L>PI THEN L=2*PI-L
- 3640 ZR=L:ZD=ZR*180/PI
- 3650 GOTO 3830
- 3660 '
- 3670 '.....formula elements
- 3680 F0=1/TAN(C/2) 'cotangent C/2
- 3690 F1=F0*SIN((LB-LA)/2)/COS((LB+LA)/2)
- 3700 IF LB+LA=0 THEN F2=F0*COS((LB-LA)/2)/SIN(9.8E-08):GOTO 3720
- 3710 F2=F0*COS((LB-LA)/2)/SIN((LB+LA)/2)
- 3720 F3=ATN(F1)
- 3730 F4=ATN(F2)
- 3740 '
- 3750 '.....bearings
- 3760 Y=F4+F3 'bearing at point B
- 3770 IF LA<0 AND LB<0 THEN Y=Y+PI:GOTO 3790 'A & B both in southern hemisphere
- 3780 IF ABS(LA)>ABS(LB)THEN Y=Y+PI
- 3790 IF Y<0 THEN Y=Y+2*PI
- 3800 IF Y>=(2*PI)THEN Y=Y-2*PI
- 3810 YD=Y*180/PI 'bearing in degrees at point B
- 3820 '
- 3830 X=F4-F3 'bearing at point A
- 3840 IF LA<0 AND LB<0 THEN X=X+PI:GOTO 3860 'A & B both in southern hemisphere
- 3850 IF ABS(LA)>ABS(LB)THEN X=X+PI
- 3860 IF X<0 THEN X=X+2*PI
- 3870 IF X>=(2*PI)THEN X=X-2*PI
- 3880 XR=2*PI-X 'reciprocal
- 3890 IF XR<0 THEN XR=XR+2*PI
- 3900 IF XR>=(2*PI)THEN XR=XR-2*PI
- 3910 XD=XR*180/PI 'bearing in degrees at point A
- 3920 '
- 3930 '.....distance
- 3940 IF RLO(1)=RLO(2)THEN ZR=ABS(LB-LA):GOTO 3980
- 3950 IF LA=LB THEN LB=LB+9.8E-08:GOTO 3400 'avoids trig function of angle 0
- 3960 F5=TAN((LB-LA)/2)*SIN(F4)/SIN(F3) 'F5=tan ZR/2 (ZR=distance angle)
- 3970 ZR=ABS(2*ATN(F5)) 'distance angle in radians
- 3980 ZD=ZR*180/PI 'distance angle in degrees
- 3990 '
- 4000 RETURN
- 4010 '
- 4020 '.....LATLONG - 20 NOV 85 rev. 12 FEB 94
- 4030 CLS
- 4040 IF FAR$<>""THEN 5330
- 4050 COLOR 15,2
- 4060 PRINT " LATITUDE & LONGITUDE Data Base";TAB(57);"by George Murphy VE3ERP ";
- 4070 COLOR 1,0:PRINT STRING$(80,223);
- 4080 COLOR 7,0
- 4090 PRINT " Press number in < > to:"
- 4100 PRINT UL$;
- 4110 PRINT " < 1 > ADD a listing"
- 4120 PRINT " < 2 > FIND or EDIT a listing"
- 4130 PRINT " < 3 > DISPLAY listings"
- 4140 PRINT UL$;
- 4150 PRINT " < 0 > EXIT"
- 4160 Z$=INKEY$
- 4170 IF Z$="1"THEN CLS:GOTO 4520
- 4180 IF Z$="2"THEN CLS:GOTO 5330
- 4190 IF Z$="3"THEN CLS:GOSUB 4660:GOTO 4920
- 4200 IF Z$="0"THEN 380
- 4210 GOTO 4160
- 4220 '
- 4230 '.....save data
- 4240 PRINT " SAVING DATA to DISK
- 4250 OPEN "O",1,"\data\latlong\LATLONG.DAT"
- 4260 FOR Z=1 TO N
- 4270 WRITE# 1,A$(Z,1),A$(Z,2),A$(Z,3),A$(Z,4)
- 4280 NEXT Z
- 4290 CLOSE
- 4300 GOTO 4030
- 4310 '
- 4320 '.....change text to capital letters
- 4330 FOR U=1 TO LEN(I$)
- 4340 V=ASC(MID$(I$,U,1))
- 4350 IF V>96 AND V<123 THEN MID$(I$,U,1)=CHR$(V-32)
- 4360 NEXT U
- 4370 RETURN
- 4380 '.....inputs
- 4390 INPUT " ENTER: City or town...................";I$:GOSUB 4320
- 4400 GOSUB 4480:RETURN
- 4410 INPUT " ENTER: Province, State or Country.....";I$:GOSUB 4320
- 4420 GOSUB 4480:RETURN
- 4430 INPUT " ENTER: Latitude (minus if South)......";I$
- 4440 GOSUB 4480:RETURN
- 4450 INPUT " ENTER: Longitude (minus if West)......";I$
- 4460 GOSUB 4480:RETURN
- 4470 '
- 4480 LOCATE CSRLIN-1:PRINT STRING$(6,32)
- 4490 LOCATE CSRLIN-1,39:PRINT " ";I$;" "
- 4500 RETURN
- 4510 '
- 4520 '.....new listing
- 4530 N=N+1
- 4540 PRINT " NEW LISTING"
- 4550 PRINT UL$;
- 4560 FOR Z=1 TO 4
- 4570 ON Z GOSUB 4390,4410,4430,4450
- 4580 A$(N,Z)=I$
- 4590 NEXT Z
- 4600 CLS
- 4610 Z=N
- 4620 IF LEN(A$(N,1))+LEN(A$(N,2))<21 THEN 6510
- 4630 BEEP:PRINT:PRINT " TOO LONG! Please abbreviate one or both names"
- 4640 PRINT:GOTO 6510
- 4650 '
- 4660 '.....compile
- 4670 IF A$(1,1)<>""THEN 4760
- 4680 FOR Y=1 TO N
- 4690 FOR X=1 TO 4
- 4700 A$(Y,X)=A$(Y+1,X)
- 4710 NEXT X
- 4720 NEXT Y
- 4730 N=N-1
- 4740 GOTO 4670
- 4750 '
- 4760 '.....sort
- 4770 SN=N:SM=SN:PRINT " SORTING at level.....";
- 4780 SM=INT(SM/2):IF SM=0 THEN CLS:GOTO 4900
- 4790 LOCATE 1,20:PRINT USING "####";SM*2
- 4800 SK=SN-SM:SJ=1
- 4810 SI=SJ
- 4820 SL=SI+SM
- 4830 IF A$(SI,1)<=A$(SL,1)THEN 4880
- 4840 FOR X=1 TO 4
- 4850 SWAP A$(SI,X),A$(SL,X)
- 4860 NEXT X
- 4870 SI=SI-SM:IF SI>0 THEN 4820
- 4880 SJ=SJ+1:IF SJ>SK THEN 4780
- 4890 GOTO 4810
- 4900 RETURN
- 4910 '
- 4920 '.....screen display
- 4930 CLS
- 4940 LIN=0 'line no.
- 4950 '
- 4960 FOR Z=1 TO N STEP 2
- 4970 LIN=LIN+1
- 4980 IF LIN=1 THEN LOCATE 1
- 4990 GOSUB 5180 'determine NEWS suffix
- 5000 PRINT USING U5$;ABS(Z1);:PRINT Z1$;" ";
- 5010 PRINT USING U5$;ABS(Z2);:PRINT Z2$;" ";A$(Z,1);
- 5020 IF A$(Z,2)=""THEN 5030 ELSE PRINT ", ";A$(Z,2);
- 5030 IF A$(Z+1,1)=""THEN 5090
- 5040 PRINT TAB(41);USING U5$;ABS(Z3);:PRINT Z3$;" ";
- 5050 PRINT USING U5$;ABS(Z4);:PRINT Z4$;" ";A$(Z+1,1);
- 5060 IF A$(Z+1,2)=""THEN 5070 ELSE PRINT ", ";A$(Z+1,2);
- 5070 IF LIN<24 THEN PRINT "":GOTO 5090
- 5080 GOSUB 7170:LIN=0:CLS
- 5090 NEXT Z
- 5100 '
- 5110 IF LIN>21 THEN GOSUB 7170:GOTO 5120 ELSE 5130
- 5120 CLS
- 5130 PRINT UL$;
- 5140 PRINT N;"listings as of ";DATE$
- 5150 GOSUB 7170
- 5160 COLOR 7,0:CLS:GOTO 4230 'save data
- 5170 '
- 5180 '.....determine NSEW suffix
- 5190 E$=CHR$(248)
- 5200 Z1=VAL(A$(Z,3)):IF Z1<0 THEN Z1$=E$+"S"ELSE Z1$=E$+"N"
- 5210 Z2=VAL(A$(Z,4)):IF Z2<0 THEN Z2$=E$+"W"ELSE Z2$=E$+"E"
- 5220 Z3=VAL(A$(Z+1,3)):IF Z3<0 THEN Z3$=E$+"S"ELSE Z3$=E$+"N"
- 5230 Z4=VAL(A$(Z+1,4)):IF Z4<0 THEN Z4$=E$+"W"ELSE Z4$=E$+"E"
- 5240 RETURN
- 5250 '
- 5260 '.....menu return
- 5270 'CLS
- 5280 PRINT:PRINT " Nothing starting with ";I$;" on file...."
- 5290 PRINT:PRINT " Press SPACE BAR to return to Menu
- 5300 Z$=INKEY$:IF Z$=" "THEN CLS:GOTO 4060
- 5310 GOTO 5300
- 5320 '
- 5330 '.....find location
- 5340 LOCATE 1
- 5350 PRINT " Press number in ( ) to enter what you know about sought location:"
- 5360 PRINT UL$;
- 5370 PRINT " (1) City, Town, Province, State or Country"
- 5380 PRINT " (2) Latitude and Longitude"
- 5390 Z$=INKEY$
- 5400 IF Z$="1"THEN CLS:GOTO 5730
- 5410 IF Z$="2"THEN CLS:GOTO 5440
- 5420 GOTO 5390
- 5430 '
- 5440 '.....find latitude & longitude
- 5450 GOSUB 4430:LA$=I$:GOSUB 4450:LO$=I$
- 5460 LAT=VAL(LA$):LON=VAL(LO$) 'sought co-ordinates
- 5470 CLS:LOCATE 24,18
- 5480 PRINT " SEARCHING for Latitude ";USING "+##.#";LAT;
- 5490 PRINT ", Longitude ";USING "+###.#";LON
- 5500 D=PI 'distance angle
- 5510 A=VAL(LA$)*PI/180
- 5520 L1=VAL(LO$)*PI/180
- 5530 FOR X=1 TO N
- 5540 B=VAL(A$(X,3)):L2=VAL(A$(X,4))
- 5550 IF A=B AND L1=L2 THEN 5440
- 5560 B=B*PI/180:L2=L2*PI/180
- 5570 Z=SIN(A)*SIN(B)+COS(A)*COS(B)*COS(ABS(L1-L2)):GOSUB 6810
- 5580 IF RC<D THEN D=RC:LL=X
- 5590 NEXT X
- 5600 '
- 5610 CLS:Z=LL
- 5620 IF LAT>0 THEN LAT$=E$+"N"ELSE LAT$=E$+"S"
- 5630 IF LON>0 THEN LON$=E$+"E"ELSE LON$=E$+"W"
- 5640 DIST=D*180/PI*40000/360:D$="kilometers"
- 5650 DIST=INT(DIST*10+0.5)/10 'round-off to 1 decimal place
- 5660 PRINT " Target location is ";USING U1$;ABS(LAT);:PRINT LAT$;",";
- 5670 PRINT USING U2$;ABS(LON);:PRINT LON$
- 5680 IF DIST=0 THEN 5700
- 5690 PRINT " Nearest location on file,";DIST;D$;" from target location, is:"
- 5700 PRINT UL$;
- 5710 GOSUB 6310:GOTO 6140
- 5720 '
- 5730 '.....find name
- 5740 LOCATE 1
- 5750 INPUT" ENTER first few characters of Town, State, Country, Prefix, etc.";I$
- 5760 GOSUB 4320 'capitalize
- 5770 CLS
- 5780 LOCATE 24,35:PRINT " SEARCHING...";
- 5790 LOCATE 1
- 5800 L=LEN(I$):F=0
- 5810 FOR Z=1 TO N
- 5820 FOR Y=1 TO 2:IF LEFT$(A$(Z,Y),L)<>I$ THEN 5900
- 5830 F=F+1
- 5840 F$(F,2)=STR$(Z)
- 5850 F$(F,1)=A$(Z,1)
- 5860 IF A$(Z,2)<>""THEN F$(F,1)=F$(F,1)+", "+A$(Z,2)
- 5870 IF F$(F,1)+F$(F,2)=F$(F-1,1)+F$(F-1,2)THEN F=F-1:GOTO 5910
- 5880 IF F<27 THEN 5900
- 5890 CLS:PRINT" LONG LIST - Please enter more letters !":GOTO 5750
- 5900 NEXT Y
- 5910 NEXT Z:IF F=0 THEN 5260
- 5920 CLS:IF F=1 THEN Z=VAL(F$(F,2)):GOTO 6130
- 5930 '
- 5940 PRINT " Location names starting with ";
- 5950 COLOR 0,7:PRINT " ";I$;" ":COLOR 7,0
- 5960 PRINT UL$;
- 5970 CF=CINT(F/2)
- 5980 FOR Z=1 TO CINT(F/2)
- 5990 PRINT " (";CHR$(96+Z);") ";F$(Z,1);TAB(41);
- 6000 PRINT "(";CHR$(96+CF+Z);") ";F$(Z+CF,1)
- 6010 NEXT Z
- 6020 IF F/2<>INT(F/2)THEN LOCATE CSRLIN-1,41:PRINT STRING$(39,32)
- 6030 PRINT UL$;
- 6040 LIN=CSRLIN
- 6050 PRINT " Press letter in ( ) to select listing or <0> to return to menu"
- 6060 Z$=INKEY$:IF Z$=""THEN 6060
- 6070 IF Z$="0"THEN 4030
- 6080 Z=ASC(Z$)-96
- 6090 IF Z>=1 AND Z<=F THEN Y=Z:Z=VAL(F$(Y,2)):CLS:GOTO 6130
- 6100 GOTO 6060
- 6110 '
- 6120 '.....display listing
- 6130 GOSUB 6310
- 6140 PRINT " Press number in ( ) for next step:":PRINT UL$;
- 6150 IF FAR$=""THEN 6180
- 6160 PRINT " (1) SELECT this listing for Great Circle calculation
- 6170 IF FAR$<>""THEN 6200
- 6180 PRINT " (2) EDIT Listing
- 6190 PRINT " (3) DELETE Listing
- 6200 PRINT UL$;
- 6210 PRINT " (0) RETURN to menu
- 6220 Z$=INKEY$
- 6230 IF FAR$=""THEN 6260
- 6240 IF Z$="1"THEN CLS:GOTO 6430
- 6250 IF FAR$<>""THEN 6280
- 6260 IF Z$="2"THEN CLS:GOTO 6510
- 6270 IF Z$="3"THEN BEEP:PRINT:GOTO 6680
- 6280 IF Z$="0"THEN 4030
- 6290 GOTO 6220
- 6300 '
- 6310 PRINT" line 1: ";A$(Z,1)
- 6320 PRINT" line 2: ";A$(Z,2)
- 6330 B=VAL(A$(Z,3)):IF B<0 THEN B$=E$+"S"ELSE B$=E$+"N"
- 6340 PRINT" line 3: ";
- 6350 PRINT"Lat ";USING "###.###";ABS(B);:PRINT B$
- 6360 PRINT" line 4: ";
- 6370 B=VAL(A$(Z,4)):IF B<0 THEN B$=E$+"W"ELSE B$=E$+"E"
- 6380 PRINT"Long ";USING "###.###";ABS(B);:PRINT B$
- 6390 PRINT" Solar Time Zone UTC";USING "+##";B/15
- 6400 PRINT UL$;
- 6410 RETURN
- 6420 '
- 6430 '.....assign variables for Great Circle calculations
- 6440 P$(POSN)=A$(Z,1)
- 6450 IF A$(Z,2)<>""THEN P$(POSN)=P$(POSN)+", "+A$(Z,2)
- 6460 LA(POSN)=VAL(A$(Z,3))
- 6470 LO(POSN)=VAL(A$(Z,4))
- 6480 GOTO 10
- 6490 '
- 6500 '.....change listing
- 6510 GOSUB 6310:PRINT " Press number in ( ) to change listing:":PRINT UL$;
- 6520 FOR Y=1 TO 4:PRINT " (";Y;") Change Line";Y:NEXT Y
- 6530 PRINT " ( 5 ) O.K. as is
- 6540 Z$=INKEY$:Q=VAL(Z$):IF Q<1 OR Q>5 THEN 6650
- 6550 IF Z$="1"THEN GOSUB 4390:A$(Z,1)=I$:GOSUB 6610:CLS:GOTO 6510
- 6560 IF Z$="2"THEN GOSUB 4410:A$(Z,2)=I$:GOSUB 6610:CLS:GOTO 6510
- 6570 IF Z$="3"THEN GOSUB 4430:A$(Z,3)=I$:CLS:GOTO 6510
- 6580 IF Z$="4"THEN GOSUB 4450:A$(Z,4)=I$:CLS:GOTO 6510
- 6590 IF Z$="5"THEN CLS:GOTO 4230
- 6600 '
- 6610 IF LEN(A$(Z,1))+LEN(A$(Z,2))<21 THEN 6660
- 6620 BEEP:PRINT " TOO LONG! Please abbreviate lines 1 and/or 2...."
- 6630 PRINT " Press any key to continue.........."
- 6640 IF INKEY$=""THEN 6640 ELSE CLS:GOTO 6500
- 6650 GOTO 6540
- 6660 RETURN
- 6670 '
- 6680 '.....delete listing
- 6690 BEEP:COLOR 0,7
- 6700 PRINT " Are you SURE you want to delete this file? (y/n) "
- 6710 COLOR 7,0
- 6720 Z$=INKEY$
- 6730 IF Z$="y"THEN 6760
- 6740 IF Z$="n"THEN CLS:GOTO 6120
- 6750 GOTO 6720
- 6760 CLS:PRINT " LISTING DELETED. File being re-sorted.....please wait...."
- 6770 FOR X=Z TO N:LOCATE 12,39:PRINT N-X
- 6780 FOR Y=1 TO 4
- 6790 A$(X,Y)=A$(X+1,Y):NEXT Y:NEXT X:N=N-1:GOTO 4230 'save data
- 6800 '
- 6810 '.....ACS, ASN 'GOSUB HERE TO GET ASN/ACS
- 6820 IF Z=0 THEN RC=PI/2:GOTO 6850 'Z=VALUE FROM PROGRAM
- 6830 IF Z=1 THEN RC=0:GOTO 6850
- 6840 RC=-ATN(Z/SQR(1-Z^2))+PI/2 'RC=ANGLE IN RADIANS IF Z=COS
- 6850 RS=PI/2-RC 'RS=ANGLE IN RADIANS IF Z=SIN
- 6860 RETURN
- 6870 '
- 6880 '....clear memories
- 6890 FOR M=1 TO 2
- 6900 P$(M)="":LA(M)=0:LO(M)=0
- 6910 NEXT M
- 6920 POSN=0:FAR$=""
- 6930 Z$="":QX=0:QY=0:FF=0
- 6940 GOTO 380
- 6950 '
- 6960 '.....preface
- 6970 T=7
- 6980 PRINT TAB(T);
- 6990 PRINT "This program calculates Great Circle paths, bearings and distances"
- 7000 PRINT TAB(T);
- 7010 PRINT "between any two points on earth, including those on or very close"
- 7020 PRINT TAB(T);
- 7030 PRINT "to the same meridian, the equator, or the earth's poles. Several"
- 7040 PRINT TAB(T);
- 7050 PRINT "intermediate points are also calculated as an aid in plotting the"
- 7060 PRINT TAB(T);
- 7070 PRINT "path on a flat chart or map drawn in any projection. Solar time"
- 7080 PRINT TAB(T);
- 7090 PRINT "difference between the two end points is also shown."
- 7100 PRINT
- 7110 PRINT TAB(T);
- 7120 PRINT "Also included is a data base of over 500 locations that can be"
- 7130 PRINT TAB(T);
- 7140 PRINT "inserted into the program, and which can be edited by the user."
- 7150 RETURN
- 7160 '
- 7170 'HARDCOPY
- 7180 GOSUB 7290:LOCATE 25,2:COLOR 14,6
- 7190 PRINT " Press 1 to print screen, 2 to print screen & ";
- 7200 PRINT "advance paper, or 3 to continue.";:COLOR 7,0
- 7210 Z$=INKEY$:IF Z$="3"THEN GOSUB 7290:RETURN
- 7220 IF Z$="1"OR Z$="2"THEN GOSUB 7290:GOTO 7240
- 7230 GOTO 7210
- 7240 FOR QX=1 TO 24:FOR QY=1 TO 80
- 7250 LPRINT CHR$(SCREEN(QX,QY));
- 7260 NEXT QY:NEXT QX
- 7270 IF Z$="2"THEN LPRINT CHR$(12)
- 7280 GOTO 7180
- 7290 LOCATE 25,1:PRINT STRING$(80,32);:RETURN
-